﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DaoShopOnline;

namespace ManageCategoriesProducts
{
    public partial class AddCategoryWindow : Window
    {
        public Category newCategory
        {
            get;
            private set;
        }

        public AddCategoryWindow()
        {
            InitializeComponent();

            this.newCategory = new Category();
            this.DataContext = this.newCategory;
            this.newCategory.CategoryName = String.Empty;
            this.TextBoxCategoryName.Focus();
        }

        private void buttonAdd_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxCategoryName.Text.Trim() == string.Empty)
            {
                ErrorWindow errorWindow = new ErrorWindow("Cannot add category!",
                    "Category name length must be between 1 and 20.");
                errorWindow.ShowDialog();
            }
            else
            {
                this.DialogResult = true;
            }
        }

        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}
